<template>
  <div>
    测试页面
    <div>
        {{ msg ? msg : '没数据'}}
        <a-button type="primary" @click="testLoading">测试全局Loading请求</a-button>
    </div>
  </div>
</template>

<script setup>
  import { ref } from 'vue'
  import { getJson } from './api'
  const count = ref(0)
  const msg = ref('')
  let timer
  const getJsonData = () => {
    getJson().then(res => {
      console.log(res, 'res')
      if (res.code == 1) {
        msg.value = res.rows.msg
      }
    })
  }
  const testLoading = () => {
    count.value = 0
    timer = setInterval(() => {
      if (count.value >= 9) {
       clearInterval(timer)
       return
      }
      count.value++
      getJsonData()
    }, 0);
  }
</script>